package com.koylu.validator;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

public class Parameter {
	
	private String type;
	private String key;
	
	private static Map typeMap;
	private static Map keyMap;
	
	static{
		typeMap = new HashMap();
		typeMap.put("parameter", new Boolean(true));
		typeMap.put("message", new Boolean(true));
		
		keyMap = new HashMap();
		keyMap.put("submittedValue", new Boolean(true));
		keyMap.put("relValue", new Boolean(true));
		keyMap.put("mask", new Boolean(true));
		keyMap.put("min", new Boolean(true));
		keyMap.put("max", new Boolean(true));
		keyMap.put("message", new Boolean(true));
	}
	
	public String getType() {
		return type;
	}
	public void setType(String type) {
		if(typeMap.containsKey(type)){
			this.type = type;	
		}else{
			throw new RuntimeException("Invalid Parameter Type:"+type);
		}		
	}
	public String getKey() {
		return key;
	}
	public void setKey(String key) {
		if(keyMap.containsKey(key)){
			this.key = key;	
		}else{
			throw new RuntimeException("Invalid Parameter Key:"+key);
		}		
	}	
	public String toString() {		
		return ToStringBuilder.reflectionToString(this,ToStringStyle.MULTI_LINE_STYLE);
	}
}
